//
//  UILabel+Custom.m
//  XGT
//
//  Created by DemonLee on 15/5/28.
//  Copyright (c) 2015年 Demon. All rights reserved.
//

#import "UILabel+Custom.h"
#define kScreenWidth [UIScreen mainScreen].bounds.size.width
@implementation UILabel (Custom)


+ (UILabel *)initWithFrame:(CGRect)frame text:(NSString *)text font:(CGFloat)fontSize textAlignment:(NSTextAlignment)textAlignment texcolor:(UIColor *)color backgroundColor:(UIColor *)backgroundColor{
    CGRect myframe = frame;
    if (frame.size.width == kScreenWidth) {
        myframe.size.width = CGRectGetWidth(frame);
       
    }else{
        myframe.size.width = CGRectGetWidth(frame)*(kScreenWidth/375.0f);
    }
    
    UILabel *nameLabel = [[UILabel alloc]initWithFrame:frame];
    nameLabel.text = text;
    nameLabel.textAlignment = textAlignment;
    nameLabel.font = [UIFont systemFontOfSize:fontSize*(kScreenWidth/375.0f)];
    if (backgroundColor == nil) {
        nameLabel.backgroundColor = [UIColor clearColor];
    }else{
        nameLabel.backgroundColor = backgroundColor;
    }
    nameLabel.textColor = color;
    return nameLabel;
}


@end
